home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Chassis 6.0 ƒ / KeyDownProc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  1.7 KB  |  60 lines  |  [TEXT/KAHL]

  1. /************************************************************************************/
  2. /*    KeyDownProc                                                                        */
  3. /************************************************************************************/
  4.  
  5. #include "MyHeaders.h"
  6.  
  7. short KeyDownProc()
  8. {
  9.     short        KeyDRetCode = 0;
  10.  
  11.     testChar = BitAnd(myEvent.message,charCodeMask);    /* get the character        */
  12.  
  13.     if (BitAnd(myEvent.modifiers,cmdKey) != 0)    /* If command key is down...        */
  14.         {
  15.         worklong = MenuKey(testChar);            /* ...find menu equivalent            */
  16.         if (worklong)                            /* if there is a menu equivalent    */
  17.             {
  18.             workWindowPtr = FrontWindow();            /* which is front (active) ?    */
  19.             WorkRetCode = 
  20.                     WhichWindow(workWindowPtr, &k);            /* match ptr to table    */
  21.             if (WorkRetCode == 0)                            /* if it's a good match    */
  22.                 {                                            /* then                    */
  23.                 windSub = k;                                /*   set the subscrpt    */
  24.                 WorkRetCode = MenuProc(worklong);            /*   perform menu cmmnd    */
  25.                 }
  26.             }
  27.         else
  28.             SysBeep(0);                            /* otherwise just beep at em        */
  29.         }
  30.         
  31.     else                                        /* else...                            */
  32.     if (testChar == 0x05)                        /* If "help" key was used            */
  33.         WorkRetCode = HelpGetProc();            /* ...perform Help procedure        */
  34.         
  35.     else
  36.         {
  37.         workWindowPtr = FrontWindow();    /* which is front (active) ?    */
  38.         WorkRetCode = 
  39.                 WhichWindow(workWindowPtr, &k);    /* match ptr to table    */
  40.         if (WorkRetCode == 0)                    /* if it's a good match    */
  41.             {                                    /* then                    */
  42.             windSub = k;                        /*   set the subscrpt    */
  43.             switch (windTbl[windSub].windRec.refCon)    /* window type    */
  44.                 {
  45.                 case (ProcMain):
  46.                     WorkRetCode = MainWindowProc();
  47.                 break;
  48.                 case (ProcText):
  49.                     WorkRetCode = TextWindowProc();
  50.                 break;
  51.                 case (ProcHelp):
  52.                     WorkRetCode = HelpWindowProc();
  53.                 break;
  54.                 }
  55.             }
  56.         }
  57.  
  58.     return KeyDRetCode;
  59. }
  60.